<?php
namespace app\index\controller;

use think\Controller;
use think\Db;
use think\Request;
use think\Session;
use app\index\model\Login as LoginModel;

class Login extends Controller
{
    public $LoginModel = null;

    // 自执行
    public function _initialize()
    {
        $this->LoginModel = new LoginModel;
    }


    // 加载页面
    public function index()
    {
        // var_dump($_COOKIE);die;
        // var_dump('123456');die;
        return view('login/login',[
            'title' => '用户登陆',
        ]);
    }

    // 执行登录
    public function dologin($auto=false)
    {
        $rec = $this->LoginModel->dologin($auto);
        if($rec['status']){
            if($rec['url']){
                $this->success('登陆成功', 'index/Index/index');
            }
        }else{
            if($rec['url']){
                $this->error('请登录', 'index/login');
            }else{
                $this->error('账号或密码错误');
            }
        }
    }

}